package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zail extends zagm {
   IconSet a;
   private Style f;
   private static Object g = new Object();
   static com.aspose.cells.a.f.zi d = null;
   static HashMap e = null;

   public zail(IconSet var1, zaay var2, zfv var3, CellArea var4) {
      super(var2, var3, var4);
      if (d == null) {
         d = com.aspose.cells.a.f.zi.a(com.aspose.cells.a.c.zy.a("Aspose.Cells.StyleObject.ConditionStyle.IconImages.zip"));
         e = new HashMap();
      }

      if (var3 != null) {
         this.f = var3.b < 0 ? this.b.p.g.D() : this.b.p.g.B().a(var3.b);
      }

      this.a = var1;
   }

   private com.aspose.cells.b.a.b.zj b(int var1) throws Exception {
      com.aspose.cells.b.a.b.zj var2 = (com.aspose.cells.b.a.b.zj)e.get(var1);
      HashMap var3 = e;
      synchronized(e) {
         if (var2 == null) {
            com.aspose.cells.a.f.zh var4 = d.a(zsl.c(var1) + ".png");
            com.aspose.cells.b.a.d.za var5 = new com.aspose.cells.b.a.d.za(d.a(var4));
            byte[] var6 = new byte[(int)var4.a()];
            var5.a(var6, 0, var6.length);
            var5.l();
            com.aspose.cells.b.a.d.zh var7 = new com.aspose.cells.b.a.d.zh(var6);
            var2 = com.aspose.cells.b.a.b.za.a(var7);
            e.put(var1, var2);
         }

         return var2;
      }
   }

   private com.aspose.cells.a.d.zj a(int var1, int var2) throws Exception {
      com.aspose.cells.b.a.b.zj var3 = this.b(var1);
      com.aspose.cells.b.a.b.za var4 = new com.aspose.cells.b.a.b.za(16, 16);
      com.aspose.cells.b.a.b.zi var5 = com.aspose.cells.b.a.b.zi.a((com.aspose.cells.b.a.b.zj)var4);
      Object var6 = g;
      synchronized(g) {
         var5.a(var3, (com.aspose.cells.b.a.b.zp)(new com.aspose.cells.b.a.b.zp(0, 0, 16, 16)), (com.aspose.cells.b.a.b.zp)(new com.aspose.cells.b.a.b.zp(0, var2 * 24, 16, 16)), 2);
      }

      var5.e();
      com.aspose.cells.b.a.d.zh var9 = new com.aspose.cells.b.a.d.zh();
      var4.a(var9, ImageFormat.getPng());
      com.aspose.cells.a.d.zj var7 = com.aspose.cells.a.d.zj.a(new com.aspose.cells.b.a.b.zo(0.0F, 0.0F), new com.aspose.cells.b.a.b.zt(12.0F, 12.0F), var9);
      return var7;
   }

   protected void d() {
      zfv var1 = this.b.e.getRows().a.a(this.b.g, new zfv(this.b.h), 6);
      if (var1 == null) {
         this.c = zzk.a;
      } else {
         this.c = zaaq.a(var1.c, var1.d);
         this.f = var1.b < 0 ? this.b.p.g.D() : this.b.p.g.B().a(var1.b);
      }
   }

   int a(int var1) {
      return this.a.getType() == 21 ? this.a.getCfIcons().get(var1).getType() : this.a.getType();
   }

   int a() {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return -1;
      } else {
         ArrayList var1 = new ArrayList();

         try {
            Iterator var2 = this.a.getCfvos().iterator();

            while(var2.hasNext()) {
               ConditionalFormattingValue var3 = (ConditionalFormattingValue)var2.next();
               if (var3.f() != null) {
                  com.aspose.cells.b.a.a.ze.a(var1, (Object)this.a(var3).k());
               }
            }

            double var9 = ((zyy)this.c).k();

            for(int var4 = this.a.getCfvos().getCount() - 1; var4 >= 0; --var4) {
               ConditionalFormattingValue var5 = this.a.getCfvos().get(var4);
               double var6 = (Double)var1.get(var4);
               if (var5.isGTE()) {
                  if (var9 >= var6) {
                     return var4;
                  }
               } else if (var9 > var6) {
                  return var4;
               }
            }

            return 0;
         } catch (Exception var8) {
            return -1;
         }
      }
   }

   public com.aspose.cells.a.d.zb a(com.aspose.cells.b.a.b.zq var1, double[] var2, int var3, int var4) throws Exception {
      int var5 = this.a.getCfvos().getCount();
      int var6 = this.a();
      if (var6 == -1) {
         return null;
      } else {
         com.aspose.cells.a.d.zj var7 = null;
         if (this.a.getType() == 21) {
            if (this.a.getCfIcons().get(var6).getType() == 20) {
               var7 = null;
            } else {
               var7 = this.a(this.a.getCfIcons().get(var6).getType(), var5 - 1 - this.a.getCfIcons().get(var6).getIndex());
            }
         } else {
            if (!this.a.getReverse()) {
               var6 = var5 - 1 - var6;
            }

            var7 = this.a(this.a.getType(), var6);
         }

         com.aspose.cells.a.d.zb var8 = new com.aspose.cells.a.d.zb();
         com.aspose.cells.a.d.zb var9 = new com.aspose.cells.a.d.zb();
         if (var7 != null) {
            if (this.f == null) {
               this.f = this.b.e.getCellStyle(this.b.g, this.b.h);
            }

            var9.a((com.aspose.cells.a.d.zl)var7);
            float var10 = (float)Math.min(var2[0], var2[1]);
            var10 *= (float)this.f.getFont().getSize() / 11.0F;
            float var11 = 0.0F;
            float var12 = var1.j();
            switch(var4) {
            case 1:
               var11 = (var1.k() + var1.m()) / 2.0F - 6.0F * var10;
               break;
            case 9:
               var11 = var1.k();
               break;
            default:
               var11 = var1.m() - 12.0F * var10 - 1.0F;
            }

            if (!this.a.getShowValue()) {
               switch(var3) {
               case 1:
                  var12 = var1.j() + var1.h() / 2.0F - 6.0F * var10;
               case 7:
                  break;
               case 8:
                  var12 = var1.j() + var1.h() - 12.0F * var10;
                  break;
               default:
                  var12 = var1.j() + var1.h() / 2.0F - 6.0F * var10;
               }
            }

            var9.a(new com.aspose.cells.b.a.b.a.zi(var10, 0.0F, 0.0F, var10, var12, var11));
            var8.a(new com.aspose.cells.a.d.zn(var1));
            var8.a((com.aspose.cells.a.d.zl)var9);
         }

         return var8;
      }
   }

   public boolean c() {
      return this.a.getShowValue();
   }
}
